#include<iostream>
#include<fcntl.h>
#include<unistd.h>
#include<cstring>
#include<error.h>
using namespace std;
void Fcntl(int fd)
{
	int n = fcntl(fd,F_GETFL);
	if(n<0)
	{

		perror("fcntl");
		return;
	}
	fcntl(fd,F_SETFL,n|O_NONBLOCK);
}
int main()
{
	Fcntl(0);
	char buff[1024];
	while(true)
	{

	int n = read(0,buff,sizeof(buff));
	if(n>0)
	{

		cout<<"read a message"<<buff<<endl;
	}
	else
	{
		sleep(1);
		cout<<"error"<<error<<endl;
	}
	}
}
